﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
using System.Text;
using System.Threading.Tasks;

namespace ParkingApp.Common {
    public class CachingService {
        public const string ParkingSlotListKey = "ParkingSlotListKey";

        private static readonly ObjectCache _cache = MemoryCache.Default;

        public static T Get<T>(string key) where T : class {
            try {
                return (T)_cache[key];
            }
            catch {
                return null;
            }
        }

        public static void AddItem(string key, object objectToCache) {
            _cache.Add(key, objectToCache, DateTime.Now.AddDays(30));
        }
    }
}
